const originalArray = [
    { id: 1, name: "张三", fatherId: "1" },
    { id: 2, name: "李四", fatherId: "1" },
	{ id: 3, name: "五五", fatherId: "2" },
	{ id: 4, name: "小六", fatherId: "2" }
];

function transformArray(arr) {
    const result = [];
    const fatherMap = {};

    arr.forEach(item => {
        const fatherId = parseInt(item.fatherId);
        if (!fatherMap[fatherId]) {
            const newObj = {
                fatherId: fatherId,
                sons: []
            };
            result.push(newObj);
            fatherMap[fatherId] = newObj;
        }
        fatherMap[fatherId].sons.push({
            id: item.id,
            name: item.name
        });
    });

    return result;
}

const transformedArray = transformArray(originalArray);
console.log(JSON.stringify(transformedArray));
    